#!/bin/bash

echo "🚀 启动Python后端服务..."

# 检查Python是否安装
if ! command -v python3 &> /dev/null; then
    echo "❌ 错误: 未找到Python3，请先安装Python3"
    exit 1
fi

# 检查pip是否安装
if ! command -v pip3 &> /dev/null; then
    echo "❌ 错误: 未找到pip3，请先安装pip3"
    exit 1
fi

# 安装依赖
echo "📦 安装Python依赖..."
pip3 install -r requirements.txt

# 启动服务
echo "🌐 启动后端服务..."
python3 python_backend.py

echo "✅ 服务已启动，地址: http://localhost:5001"
echo "📝 可用接口:"
echo "  POST /run-scraper - 执行爬虫脚本"
echo "  GET  /health      - 健康检查"
echo "  GET  /scripts     - 列出可用脚本"
